package com.evil.application.pojo.dto.robot;

import com.evil.common.application.dto.order.data.ControlDataDTO;
import com.evil.common.application.dto.robot.RobotSourceDTO;
import com.evil.common.application.enums.robot.RobotFirstTriggerTypeEnum;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.*;

/**
 * 应用高级机器人执行 请求实体
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
public class AppRobotActionBatchReqDTO {

    /**
     * 触发类型
     */
    @NotNull(message = "triggerTypeEnum not null")
    private RobotFirstTriggerTypeEnum triggerTypeEnum;

    /**
     * 机器人源类型
     */
    @NotNull(message = "source not null")
    private RobotSourceDTO source;

    /**
     * 订单id
     */
    @NotEmpty(message = "orderId not null")
    private Collection<Long> orderIds;

    /**
     * 订单数据
     */
    @NotNull(message = "dataMap not null")
    private Map<Long, List<ControlDataDTO>> dataMap;

    /**
     * 原订单数据
     */
    @NotNull(message = "oldDataMap not null")
    private Map<Long, List<ControlDataDTO>> oldDataMap;

    /**
     * 应用key
     */
    @NotBlank(message = "applicationKey not null")
    private String applicationKey;

    /**
     * 记录应用层级
     */
    private List<String> logAppKeys;

    /**
     * 是否是同步
     */
    private Boolean sync;

    public AppRobotActionBatchReqDTO() {
        this.orderIds = new ArrayList<>();
        this.dataMap = new HashMap<>();
        this.oldDataMap = new HashMap<>();
        this.logAppKeys = new ArrayList<>();
        this.sync = false;
    }

    public AppRobotActionBatchReqDTO setApplicationKey(String applicationKey) {
        this.applicationKey = applicationKey;
        this.logAppKeys.add(this.applicationKey);
        return this;
    }
}
